import api from './api';

const attendanceService = {
    /**
     * 教师上课打卡
     * @param {string} context - 打卡场景描述, e.g., "日常上班打卡"
     */
    async clockIn(context) {
        try {
            const response = await api.post('/api/attendance/clock-in', { context });
            if (response.data.status === 0) {
                return response.data;
            } else {
                throw new Error(response.data.message || '打卡失败');
            }
        } catch (error) {
            const errorMessage = error.response?.data?.message || error.message || '网络错误，打卡请求失败';
            throw new Error(errorMessage);
        }
    },
};

export default attendanceService;
